/*
 *  usage.c
 *
 *  Copyright (C) 2011  Peter Polacik <polacik.p@gmx.com>
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "alogd.h"

#include <stdio.h>

void printusage(const char *progname, FILE *stream, int exitcode, int type)
{
	switch (type) {
		case 0 : /* Usage */
			fprintf(stream, "Usage: %s", progname);
			fprintf(stream, " [-hu] [-c FILE]");
			fprintf(stream, " [-b COUNT]\n");
			fprintf(stream, "\t[-d DIRECTORY]"
				" [-s SOCKET_PATH]\n");
			/*fprintf(stream, "\t[-S SERVER_ADDRESS]\n");*/
			break;
		case 1 : /* Help */
			fprintf(stream, "alogd");
			#ifdef HAVE_CONFIG_H
			fprintf(stream, " %s for %s %s compiled on %s %s\n",
				CONFIG_VERSION, CONFIG_ARCH, CONFIG_OS,
				CONFIG_DATE, CONFIG_TIME);
			#else
			fprintf(stream, "\n");
			#endif
			fprintf(stream, "Usage: %s [OPTIONS]\n\n", progname);
			fprintf(stream,
				"  -h, --help\t\tshow this help text\n");
			fprintf(stream,
				"  -u, --usage\t\tshow brief usage info\n\n");
			fprintf(stream,
				"  -c, --config=FILE\tuse FILE as config\n");
			fprintf(stream,
				"  -b, --backlog=COUNT\tallow COUNT"
				" connections at the same time\n");
			fprintf(stream,
				"  -d, --directory=DIR\tchange logging"
				" directory to DIR\n");
			fprintf(stream,
				"  -s, --socket=PATH\tuse PATH as socket"
				" address\n");
			/*fprintf(stream,
				"  -S, --server=ADDRESS\tcopy logs to"
				" server at ADDRESS\n");*/
			break;
		default :
			return;
	}
	exit(exitcode);
}
